package fly.util;

import fly.help.PrintSupport;

import java.util.*;

public class SimpleTimeZoneDemo {

    static void demo1(){
        /**
         *
         * 1 hour = 60 min = 3600 s = 3600000 ms
         */
        SimpleTimeZone stz = new SimpleTimeZone(3600000,
                "Europe/Paris",
                Calendar.MARCH, -1, Calendar.SATURDAY,
                3600000,SimpleTimeZone.UTC_TIME,
                Calendar.OCTOBER, -1, Calendar.SUNDAY,
                3600000, SimpleTimeZone.UTC_TIME,
                3600000);

        PrintSupport.sout(1);

        System.out.println( stz.getDSTSavings() );

        PrintSupport.sout(2);

//        System.out.println(
//                stz.getOffset(
//                        new Date()
//                )
//        );

        System.out.println(
                stz.getRawOffset()
        );
        PrintSupport.sout(3);

        System.out.println(stz.toString());

        PrintSupport.sout(4);

        System.out.println(stz.useDaylightTime());

    }

    public static void main(String[] args) {

        demo1();
        PrintSupport.sout("2");
        int rawOffset = -8*60*60*1000;

        SimpleTimeZone pdt = new SimpleTimeZone(
                rawOffset, TimeZone.getAvailableIDs(rawOffset)[0]
        );

        pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000);
        pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);

        System.out.println(pdt.getDisplayName());
        System.out.println(pdt.getDSTSavings());
        System.out.println(pdt.toString());
    }
}
